package com.hyt.it.ogt.ks.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * @author liuq
 * @ClassName: ResourceServerConfig
 * @Description: 资源服务器配置
 * @date 2018年6月4日
 */
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.headers().frameOptions().disable();
        http.csrf().disable()
                .exceptionHandling()
                .and()
                .authorizeRequests()
                .mvcMatchers("/webjars/bycdao-ui/**").permitAll()
                .mvcMatchers("/webjars/springfox-swagger-ui/**").permitAll()
                .mvcMatchers("/swagger-ui.html").permitAll()
                .mvcMatchers("/doc.html").permitAll()
                .mvcMatchers("/swagger-resources/**").permitAll()
                .mvcMatchers("/v2/api-docs").permitAll()
                .mvcMatchers("v2/api-docs-ext").permitAll()
                .mvcMatchers("/actuator/shutdown").permitAll()
                .mvcMatchers("/api/**").permitAll()
                .mvcMatchers("/ks/ws/**").permitAll()
                .mvcMatchers("/ks/app/**").permitAll()
                .mvcMatchers("/ks/pc/**").permitAll()
                .mvcMatchers("/ks/mobile/monitor/**").permitAll()
                .mvcMatchers("/ks/exam-score/scoreLogin").permitAll()
//                .mvcMatchers("/ks/exam-score/queryScore").permitAll()
//                .mvcMatchers("/ks/exam-score/queryScoreDetails").permitAll()
                .mvcMatchers("/ks/infor/getRegisterInfo").permitAll()
                .mvcMatchers("/ks/infor/registerStudent").permitAll()
                .mvcMatchers("/ks/infor/uploadPhoto").permitAll()
                .mvcMatchers("/ks/infor/uploadEnclosureFile").permitAll()
                .mvcMatchers("/ks/infor/getExamInfo").permitAll()
//                .mvcMatchers("/ks/infor/getExamBaseInfo").permitAll()
                .mvcMatchers("/ks/infor/getExamInfoConfig").permitAll()
                .mvcMatchers("/ks/infor/getAgreement").permitAll()
                .mvcMatchers("/ks/infor/doLogin").permitAll()
                .mvcMatchers("/ks/infor/getPublishExam").permitAll()
                .mvcMatchers("/ks/exam-paper/getInterviewUrl").permitAll()
                .mvcMatchers("/ks/exam-paper/getCodingQuestionUrl").permitAll()                
                .mvcMatchers("/ks/wx/**").permitAll()
                .mvcMatchers("/ks/bucket/getBucketTempCredential").permitAll()
                .mvcMatchers("/ks/collect/log/**").permitAll()
                .mvcMatchers("/actuator/health").permitAll()
                .mvcMatchers("/ks/exam-score/queryXyScore").permitAll()
                .mvcMatchers("/actuator/health").permitAll()
                .mvcMatchers("/ks/test/test01").permitAll()
                .mvcMatchers("/ks/exam-paper/clearInitPaperDataByCandidateId").permitAll()
                .mvcMatchers("/ks/exam-paper/clearInitPaperDataByZkz").permitAll()
                .mvcMatchers("/ks/candidate-process/overScreenLog").permitAll()
                .mvcMatchers("/ks/pc/monitor/secondValidFace").permitAll()
                .mvcMatchers("/ks/infor/unifiedLogin").permitAll()
                .mvcMatchers("/ks/infor/examList").permitAll()
                .mvcMatchers("/ks/exam/office/getExamOfficeInfo").permitAll()
                .mvcMatchers("/ks/exam/office/getExamOfficeList").permitAll()
                .mvcMatchers("/ks/candidate-log-answer/saveAnswerLog").permitAll()
                .mvcMatchers("/ks/candidate-log-other/saveOtherLog").permitAll()
                .mvcMatchers("/ks/candidateOperationTrackLog/syncEsByExamId/**").permitAll()
                .mvcMatchers("/ks/candidateOperationTrackLog/syncEsAll").permitAll()

//                .mvcMatchers("/ks/infor/getCountDown").permitAll()
//                .mvcMatchers("/ks/infor/getCandidateInfo").permitAll()
//                .mvcMatchers("/ks/exam-paper/test").permitAll()
//                .mvcMatchers("/ks/exam-paper/initPaper").permitAll()
//                .mvcMatchers("/ks/exam-paper/question").permitAll()
//                .mvcMatchers("/ks/candidate-process/getMobileLoginStatus").permitAll()
                .anyRequest().authenticated()
//                .anyRequest().permitAll()
                .and()
                .httpBasic();
    }
}
